async function Vigilance(ele,src, postion, width, height) {
    let waitFor = new Promise(function(resolve, reject){
                var c = ele  
                 c.width =width
			     c.height = height   
                var ctx = c.getContext("2d");
                var img = new Image()
                img.src = src
                img.onload = function () {
                    // 设置图片在canvas上 前面两个0,0是边距, 后面是宽高
                    ctx.drawImage(img, 0, 0,width, height);
                    // 添加文字 后面两个数字是坐标
                    // ctx.font  = "20px sans-serif"
                    // ctx.fillStyle = '#e22018'
                    // ctx.fillText("添加文字", 125, 137);
                 ctx.lineWidth = 4;
                    // 画矩形 前两个数字是坐标, 后面是矩形的宽高 fillRect是填充的
                    ctx.strokeStyle = 'red'
                    ctx.strokeRect(   postion.top_left.x,
                    postion.top_left.y,
                    postion.bottom_right.x - postion.top_left.x,
                    postion.bottom_right.y - postion.top_left.y);
                     ctx.stroke();
                   resolve(c.toDataURL());
                }
    })
     return await waitFor.then(res => {
        return res
    })
            
}

export default Vigilance